package com.egao.orderB.controller;

import com.egao.common.core.annotation.ApiPageParam;
import com.egao.common.core.annotation.OperLog;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.orderB.entity.CustomerMaintainFee;
import com.egao.orderB.service.CustomerMaintainFeeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


/**
 *
 * 货代运费维护
 * @author : Doman
 * @date : 2021-07-15 14:12:35
 * @version ：1.0
 */

@Api(tags = "货代运费维护")
@RestController
@RequestMapping("/api/orderB/customerMaintainFee")
public class CustomerMaintainFeeController extends BaseController {

	@Autowired
	private CustomerMaintainFeeService customerMaintainFeeService;

	/**
	 * 分页查询列表
	 */
//	@PreAuthorize("hasAuthority('orderB:customerMaintainFee:list')")
    //@OperLog(value = "货代运费维护", desc = "分页查询")
    @ApiOperation(value ="分页查询货代运费维护",notes = "" +
        "limit:每页显示几行 必填\n" +
        "page:第几页 必填\n" +
        "customerId:客户id\n" +
        " \n\n\n" +
        "返回的结果:\n" +
        "id:id\n" +
        "customerId:客户id\n" +
        "province:省\n" +
        "city:市\n" +
        "district:县区\n" +
        "town:镇\n" +
        "miles:公里数\n" +
        "boxType:箱型\n" +
//        "price:价格\n" +
//        "driverPrice:司机价格\n" +
        "commission:佣金\n" +
        "address:详细地址\n" +
        "pinyin:地址转拼音\n" +
        "dock:口岸\n" +
        "remark:备注\n" +
        "createTime:创建时间\n" +
        "createUser:创建人\n" +
        "updateTime:更新时间\n" +
        "updateUser:更新人\n" +
        "",httpMethod = "POST")
    @ApiPageParam
    @PostMapping("/page")
    public JsonResult page(PageResult2<T> page, CustomerMaintainFee customerMaintainFee) throws Exception{
        return customerMaintainFeeService.list(page, customerMaintainFee, getLoginUser());
    }

    /**
     * 查询全部货代运费维护
     */
//    @PreAuthorize("hasAuthority('orderB:customerMaintainFee:list')")
    //@OperLog(value = "货代运费维护", desc = "查询全部")
    @ApiOperation("查询全部货代运费维护")
    @PostMapping("/list")
    public JsonResult list(CustomerMaintainFee customerMaintainFee){
        return customerMaintainFeeService.list(customerMaintainFee, getLoginUser());
    }

    /**
     * 根据id查询货代运费维护
     */
//    @PreAuthorize("hasAuthority('orderB:customerMaintainFee:list')")
    //@OperLog(value = "货代运费维护", desc = "根据id查询")
    @ApiOperation("根据id查询货代运费维护")
    @PostMapping("/get")
    public JsonResult get(CustomerMaintainFee customerMaintainFee) {
        return customerMaintainFeeService.getById(customerMaintainFee);
		// 使用关联查询
        //PageParam<customerMaintainFee> pageParam = new PageParam<>();
		//pageParam.put("id", id);
        //List<customerMaintainFee> records = customerMaintainFeeService.listAll(pageParam.getNoPageParam());
        //return JsonResult.ok().setData(pageParam.getOne(records));
    }


    /**
     * 添加货代运费维护
     */
//    @PreAuthorize("hasAuthority('orderB:customerMaintainFee:save')")
    @OperLog(value = "货代运费维护", desc = "添加", param = false, result = true)
    @ApiOperation(value ="添加货代运费维护",notes = "" +
            "customerId:客户id\n" +
            "province:省\n" +
            "city:市\n" +
            "district:县区\n" +
            "town:镇\n" +
            "miles:公里数\n" +
            "boxType:箱型\n" +
            "price:价格\n" +
//            "driverPrice:司机价格\n" +
//            "commission:佣金\n" +
            "address:详细地址\n" +
            "pinyin:地址转拼音\n" +
            "dock:口岸\n" +
            "remark:备注\n" +
        "",httpMethod = "POST")
    @PostMapping("/save")
    public JsonResult save(Model model, CustomerMaintainFee customerMaintainFee) {
        return customerMaintainFeeService.save(customerMaintainFee, getLoginUser());
    }

    /**
     * 修改货代运费维护
     */
//    @PreAuthorize("hasAuthority('orderB:customerMaintainFee:update')")
    @OperLog(value = "货代运费维护", desc = "修改", param = false, result = true)
    @ApiOperation(value ="修改货代运费维护",notes = "" +
            "id:id\n" +
            "customerId:客户id\n" +
            "province:省\n" +
            "city:市\n" +
            "district:县区\n" +
            "town:镇\n" +
            "miles:公里数\n" +
            "boxType:箱型\n" +
            "price:价格\n" +
//            "driverPrice:司机价格\n" +
//            "commission:佣金\n" +
            "address:详细地址\n" +
            "pinyin:地址转拼音\n" +
            "dock:口岸\n" +
            "remark:备注\n" +
        "",httpMethod = "POST")
    @PostMapping("/update")
    public JsonResult update(Model model, CustomerMaintainFee customerMaintainFee) {
        return customerMaintainFeeService.update(customerMaintainFee, getLoginUser());
    }

    /**
     * 删除货代运费维护
     */
//    @PreAuthorize("hasAuthority('orderB:customerMaintainFee:remove')")
    @OperLog(value = "货代运费维护", desc = "删除", result = true)
    @ApiOperation("删除货代运费维护")
    @PostMapping("/remove")
    public JsonResult remove(CustomerMaintainFee customerMaintainFee ) {
        return customerMaintainFeeService.remove(customerMaintainFee, getLoginUser());
    }

    /**
     * excel导入用户
     */
    @OperLog(value = "货代运费维护", desc = "excel导入", param = false, result = true)
    @ApiOperation("excel导入货代运费维护")
    @Transactional
    @PostMapping("/import")
    public JsonResult importBatch(MultipartFile file) {
        return customerMaintainFeeService.importBatch(file, getLoginUser());
    }


    /**
     * 批量添加货代运费维护
     */
    /**@RequiresPermissions("orderB:customerMaintainFee:save")
    @OperLog(value = "货代运费维护", desc = "批量添加", param = false, result = true)
    @ResponseBody
    @PostMapping("/saveBatch")
    public JsonResult saveBatch(@RequestBody List<CustomerMaintainFee> list) {
        if (customerMaintainFeeService.saveBatch(list)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }*/

    /**
     * 批量修改货代运费维护
     */
    /**@RequiresPermissions("orderB:customerMaintainFee:update")
    @OperLog(value = "货代运费维护", desc = "批量修改", result = true)
    @ResponseBody
    @PostMapping("/updateBatch")
    public JsonResult updateBatch(@RequestBody BatchParam<CustomerMaintainFee> batchParam) {
        if (batchParam.update(customerMaintainFeeService, "")) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }*/

    /**
     * 批量删除货代运费维护
     */
    /**@RequiresPermissions("orderB:customerMaintainFee:remove")
    @OperLog(value = "货代运费维护", desc = "批量删除", result = true)
    @ResponseBody
    @PostMapping("/removeBatch")
    public JsonResult removeBatch(@RequestBody List<Integer> ids) {
        if (customerMaintainFeeService.removeByIds(ids)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }*/

}
